import * as React from "react"; import { Provider, Flex, Header, Input } from "@fluentui/react-northstar"; import { useState, useEffect, useRef } from "react"; import { useTeams } from "msteams-react-base-component"; import { app, pages } from "@microsoft/teams-js"; /** * Implementation of <%= tabTitle %> configuration page */ export const <%=tabReactComponentName%>Config = () => { const [{ inTeams, theme, context }] = useTeams({}); const [text, setText] = useState(); const entityId = useRef(""); const onSaveHandler = (saveEvent: pages.config.SaveEvent) => { const host = "https://" + window.location.host; pages.config.setConfig({ contentUrl: host + "/<%=tabName%>/?name={loginHint}&tenant={tid}&group={groupId}&theme={theme}", websiteUrl: host + "/<%=tabName%>/?name={loginHint}&tenant={tid}&group={groupId}&theme={theme}", suggestedDisplayName: "<%=tabTitle%>", removeUrl: host + "/<%=tabName%>/remove.html?theme={theme}", entityId: entityId.current }).then(() => { saveEvent.notifySuccess(); }); }; useEffect(() => { if (context) { setText(context.page.id); entityId.current = context.page.id; pages.config.registerOnSaveHandler(onSaveHandler); pages.config.setValidityState(true); app.notifySuccess(); } // eslint-disable-next-line react-hooks/exhaustive-deps }, [context]); return (
{ if (data) { setText(data.value); entityId.current = data.value; } }} required />
); };